var chalk = require('chalk');
const pluginName = 'DonePlugin';

class DonePlugin {
    apply(compiler) {
        //编译成功时时处理
        compiler.hooks.done.tap(
            pluginName,
            async stats => {
                console.log('DONE:',stats.hasErrors(),stats.hasWarnings());
                if (stats.hasErrors()) {
					        console.log(`webpack编译错误--->${pluginName}`);
                  console.log('CAP-H5-BUILD-FAILED');
                } else {
					        console.log(`webpack编译成功--->${pluginName}`);
                    // 自检
                  console.log('CAP-H5-BUILD-SUCCESS');
                }
            }
        );
    }
}

module.exports = DonePlugin;